import { BroadCastCall } from "../../broadCast/BroadCastCall";
import { MessageBlock } from "../../../../../Framework/MQ/MessageBlock";
import { SEntityId } from "../../../../../Message/Public/SEntityId";
import { EntityUtil } from "../../../scene/layer/utils/EntityUtil";
import { SPublicMiniPlayer } from "../../../../../Message/Public/SPublicMiniPlayer";
import { MsgManager } from "../../../manager/MsgManager";
import { Language } from "../../../../../extend/language/Language";
import { NetDispatcher } from "../../../../mvc/core/NetDispatcher";
import { ServerCommand } from "../../../mvc/ServerCommand";
import { Cache } from "../../../cache/Cache";
//class CopyLeftGroupCommand
    
    export  class CopyLeftGroupCommand extends BroadCastCall
    {
        constructor(arg1: Object)
        {
            super(arg1);
            return;
        }

        public /* override */ call(arg1: MessageBlock): void
        {
            var loc2=null;
            var loc3=0;
            var loc4=null;
            super.call(arg1);
            var loc1=arg1.messageBase as SEntityId;
            if (EntityUtil.toString(loc1) != EntityUtil.toString(_cache.role.entityInfo.entityId)) 
            {
                loc2 = _cache.copy.players;
                loc3 = 0;
                while (loc3 < loc2.length) 
                {
                    if ((loc4 = loc2[loc3] as SPublicMiniPlayer).entityId.id == loc1.id) 
                    {
                        MsgManager.showRollTipsMsg(Language.getStringByParam(62026, loc4.name));
                        NetDispatcher.dispatchCmd(ServerCommand.CopyPlayersLeave, loc1);
                        loc2.splice(loc3, 1);
                        break;
                    }
                    ++loc3;
                }
                NetDispatcher.dispatchCmd(ServerCommand.Copy_PlayerInfoChange, null);
            }
            else 
            {
                if (Cache.instance.copy.isInGroup && Cache.instance.copy.isFighting) 
                {
                    _cache.copy.isInHell = false;
                }
                _cache.copy.groupInfo = null;
                _cache.copy.groupId = null;
                _cache.copy.players = [];
                _cache.copy.allocation = -1;
                if (_cache.copy.copyInfo && !(_cache.copy.copyInfo.singleMode == 1)) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(62025));
                }
                NetDispatcher.dispatchCmd(ServerCommand.Copy_PlayerInfoChange, null);
                NetDispatcher.dispatchCmd(ServerCommand.Copy_LeftGroup, null);
            }
            return;
        }
    }
